<?php

namespace app\admin\validate;

use think\Validate;

class Service extends Validate
{
    protected $scene = [
        'EditService' => ['type_id','sort','status','price','sale_price','content','top_pic','summary'],
    ];

    protected $rule =   [
        'type_id'  => 'require|number|>:0',
        'sort'  => 'require|number|>:0',
        'status'  => 'require|number|>:0',
        'price' => 'require|float|gt:0|egt:sale_price',
        'sale_price' => 'require|float|gt:0',
        'content' => 'require|max:10',
        'top_pic' => 'require',
        'summary' => 'require',
    ];

    protected $message  =   [

        'type_id'   => [
            'require'   => '请选择服务类型',
            'number'    => '请填写正确的数字'
        ],

        'sort.require' => '排序必须填写',
        'sort.number'     => '请填写正确的数字',
        'status.require' => '状态必须选择',
        'status.number'     => '请填写正确的数字',
        'content.require' => '服务简介必须填写',
        'content.max' => '服务简介字数不能超过十个字',
        'top_pic.require' => '必须上传图片',
        'summary.require' => '服务详情必须填写',

        'price' =>  [
            'require'  => '价格必须填写',
            'float'  => '请填写正确的金额，只保留小数点后两位',
            'gt'  => '原价 价格必须大于0',
            'egt'  => '销售价格 必须小于等于原价价格',
        ],

        'sale_price'    => [
            'require'  => '价格必须填写',
            'float'  => '请填写正确的金额，只保留小数点后两位',
            'gt'  => '销售价 价格必须大于0',
        ],

    ];

}
